package leecode

func IsPowerOfThree(n int) bool {
	if n == 1 {
		return true
	}
	if n <= 0 || (n > 0 && n < 3) {
		return false
	}
	for ; n > 1; n = n / 3 {
		if n%3 != 0 {
			return false
		}
	}
	return true
}
